home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Mag HDD Backup
/
Amiga Mag HDD Backup.zip
/
Amiga Mag HDD Backup
/
Alexander.img.bin
/
Alexander.img
/
tech 4.1 editorial Archive.sit
/
Nee
/
sinz.asm
< prev
Wrap
Assembly Source File
|
1993-07-16
|
20KB
|
841 lines
;LISTING 2
; by William P. Nee
; Rt 2, Box 216C
; Mason WI 54856-9302
;SIN(Z) or COS(Z) in double precision
jmp start
include execmacros.i
include intmacros.i
include dosmacros.i
include gfxmacros.i
include dpmathmacros.i
include complex.i
include menu.i
count equr a2
across equr a3
down equr a4
depth equ 5
@pset macro ;<across,down>
movea.l rp(pc),a1
move.w \1,d0
add.l xoffset(pc),d0 ;adjust across
move.l yoffset(pc),d1 ;adjust down
sub.w \2,d1
ext.l d0
ext.l d1
move.l gfxbase(pc),a6
jsr -324(a6)
endm
@cfm1 macro ;(branch to if no msg)
movea.l window(pc),a0
move.l #menunull,d0
intlib onmenu
movea.l userport(pc),a0
syslib getmsg
tst.l d0
beq \1
movea.l d0,a1
move.l im.class(a1),d2 ;IDCMP
move.w im.code(a1),d3 ;menu#
syslib replymsg
endm
@cfm2 macro ;(branch to if no msg)
movea.l userport(pc),a0
syslib getmsg
tst.l d0
beq \1
movea.l d0,a1
move.l im.class(a1),d2 ;IDCMP
move.w im.code(a1),d3 ;ASCII
move.w im.mousex(a1),d5 ;Xcoordinate
move.w im.mousey(a1),d6 ;Ycoordinate
syslib replymsg
endm
start
move.l sp,stack ;save stack pointer
open_libs ;open all the libraries we need
openlib int,done
openlib dos,close_int
openlib gfx,close_dos
openlib dpmath,close_gfx
openlib dptrans,close_gfx
doslib output
move.l d0,conhandler
; jmp setup
options
cls
linefeed
right 31
boldface
print titlemsg
normal
linefeed
print xmsg
linefeed
print palmsg
linefeed
print cmsg
linefeed
print zoommsg
linefeed
linefeed
right 24
style italics,orange,black
print lmbmsg
normal
linefeed
loop
lmb loop
setup: ;open a screen of 320 x 200
make_screen:
openscreen myscreen,close_libs
make_window
openwindow mywindow,close_screen
mode jam1
palette colormap1(pc),32
openmenu menu0
msg_check
@cfm1 msg_check
cmpi.l #menupick,d2
bne.s msg_check
eval_menunumber
tst.w d0
bne.s msg_check
move.w d1,type
closemenu
dp_newton_demo
get_values
removegadgets
lea gadget1buffer(pc),a0
bsr convertdp
movedp c1
lea gadget2buffer(pc),a0
bsr convertdp
movedp c2
lea gadget3buffer(pc),a0
bsr convertdp
movedp f1
lea gadget4buffer(pc),a0
bsr convertdp
movedp f2
lea gadget5buffer(pc),a0
bsr convertdp
movedp xleft
lea gadget6buffer(pc),a0
bsr convertdp
movedp ytop
lea gadget7buffer(pc),a0
bsr convertdp
movedp xright
lea gadget8buffer(pc),a0
bsr convertdp
movedp ybottom
movedp saveybottom
bra requester2 ;draw SMALL or LARGE
scale
move.l xlength,d0
fltdp
movedp d0,d6
movedp xright,d0
movedp xleft,d2
subdp
movedp d6,d2
divdp
movedp xinc ;x scale
movedp saveybottom,ybottom
move.l ylength,d0
fltdp
movedp d0,d6
movedp ytop,d0
movedp ybottom,d2
subdp
movedp d6,d2
divdp
movedp yinc ;y scale
bra showit
convertdp
moveq.l #0,d0
moveq.l #0,d1
moveq.l #0,d4 ;sign register
moveq.l #0,d5
moveq.l #0,d7 ;# characters right of decimal
suba.l a2,a2 ;clear a2; decimal flag register
cmpi.b #'-',(a0) ;a minus sign?
bne.s positive
bset #31,d4 ;if so set last bit in d4
addq.l #1,a0 ;move over one space
positive
getdigit
move.b (a0)+,d5 ;next value to d5
cmpi.b #'.',d5 ;a decimal?
bne.s testdigit
move.w #1,a2 ;if so, flag a2
clr.l d7 ; and clear d7
bra.s getdigit
testdigit
cmpi.b #'9',d5 ;above '9' ?
bhi.s zero_check ;branch if so
cmpi.b #'0',d5 ;below '0' ?
blt.s zero_check ;branch if so
andi.l #$0f,d5 ;convert ASCII to decimal
movedp d0,d2 ;must multiply d0 * 10
asl.l #1,d1 ;d0 * 2
roxl.l #1,d0
asl.l #1,d3 ;d2 * 8
roxl.l #1,d2
asl.l #1,d3
roxl.l #1,d2
asl.l #1,d3
roxl.l #1,d2
moveq.l #0,d6
add.l d3,d1 ;d0 = d0 + d2
addx.l d2,d0
add.l d5,d1 ; + this digit
addx.l d6,d0
addq.w #1,d7 ;number of characters done
cmpi.w #16,d7 ;up to 15 ?
bne getdigit
dperror
;moveq #1,d1 ;optional error flag
;rts
bra close_window ;error - close everything!
zero_check
movea.l a0,a5 ;return string location
tst.l d1 ;don't try to convert 0
bne.s get_exponent ;branch if not 0
tst.l d0 ;check second half
beq.s dp_done ;branch if value is 0
get_exponent
move.l #$43f,d6 ;maximum exponent
1$
subq.l #1,d6 ;decrease exponent
asl.l #1,d1 ;d0 * 2
roxl.l #1,d0 ;rotate with carry from d1
bcc.s 1$ ;branch if no carry
moveq.l #11,d5 ;move right 12 bits
shift_right
lsr.l #1,d0
roxr.l #1,d1
dbra.s d5,shift_right
adjust_exponent
swap d6 ;move to left word
asl.l #4,d6 ;move to left end
or.l d6,d0 ;put in d0
fraction_check
cmpa.l #0,a2 ;any decimal ?
beq.s do_sign ;no
subq.l #1,d7 ;decrease number of digits
bmi.s do_sign ;no digits after the decimal
decimal_adjust
move.l #$40240000,d2 ;dp 10
moveq.l #0,d3 ; part 2
divdp
dbra.s d7,decimal_adjust ;do for all digits
do_sign
or.l d4,d0 ;add sign to d0
dp_done
moveq.w #0,d6 ;all is 'ok'
rts
showit
movea.l rp(pc),a1
pcls
move.l #1,alldone ;completed? flag
move.w #0,down
lea v,a5
l1
; movedp xleft,xx
move.l xleft-v(a5),xx-v(a5)
move.l xleft+4-v(a5),xx+4-v(a5)
move.w #0,across
l2
; movedp xx,a
move.l xx-v(a5),a-v(a5)
move.l xx+4-v(a5),a+4-v(a5)
; movedp ybottom,b
move.l ybottom-v(a5),b-v(a5)
move.l ybottom+4-v(a5),b+4-v(a5)
move.w #0,count ;clear the count
l3
move.w type(pc),d0
type0
cmpi.w #0,d0
bne type1
sinz
bra compare
type1
cmpi.w #1,d0
bne type2
cosz
bra compare
type2
cmpi.w #2,d0
bne type3
sinhz
bra compare
type3
cmpi.w #3,d0
bne type4
coshz
bra compare
type4
expz
compare
fixdp
cmpi.l #50,d0
blo.s continue
move.w count,d0 ;count -> color
andi.w #31,d0
foreground ;set apen
@pset across,down ;pset the point
bra.s l4
continue
addq #1,count ;increase count
cmpa.w #48,count ;up to maximum yet ?
bne l3 ;branch if not
l4
adddp xx,xinc ;increase xx by xscale
move.l d0,xx-v(a5) ;movedp xx,xinc
move.l d1,xx+4-v(a5)
check_for_message
@cfm2 no_message
cmpi.l #mousebuttons,d2
beq zoom
tst.l d3
beq no_message
andi.l #$0000ffff,d3 ;ASCII value
cmpi.w #'1',d3 ;#1
beq do_palette1
cmpi.w #'2',d3 ;#2
beq do_palette2
cmpi.w #'3',d3 ;#3
beq do_palette3
cmpi.w #'4',d3 ;#4
beq do_palette4
cmpi.w #'5',d3 ;#5
beq do_palette5
cmpi.w #'6',d3 ;#6
beq do_palette6
cmpi.w #'7',d3 ;#7
beq do_palette7
cmpi.w #'8',d3 ;#8
beq do_palette8
cmpi.w #'9',d3 ;#9
beq do_palette9
cmpi.w #'0',d3 ;#0
beq do_palette0
cmpi.w #'c',d3
beq.s new_values
cmpi.w #'q',d3
beq close_window
cmpi.w #'x',d3
beq.s redraw_it
bra no_message
redraw_it
eori.l #1,redraw
beq draw_small
bra draw_large
new_values
pcls
closewindow
bra make_window
do_palette1
palette colormap1(pc),32
bra no_message
do_palette2
palette colormap2(pc),32
bra no_message
do_palette3
palette colormap3(pc),32
bra no_message
do_palette4
palette colormap4(pc),32
bra no_message
do_palette5
palette colormap5(pc),32
bra no_message
do_palette6
palette colormap6(pc),32
bra no_message
do_palette7
palette colormap7(pc),32
bra no_message
do_palette8
palette colormap8(pc),32
bra no_message
do_palette9
palette colormap9(pc),32
bra no_message
do_palette0
palette colormap0(pc),32
bra no_message
zoom
andi.l #$0000ffff,d5 ;mouse x
andi.l #$0000ffff,d6 ;mouse y
move.l d5,startx
move.l d6,starty
mode complement
lmb_down
@cfm2 lmb1
cmpi.w #selectup,d3
beq lmb_up
lmb1
andi.l #$0000ffff,d5 ;mouse x
andi.l #$0000ffff,d6 ;mouse y
move.l d5,endx
move.l d6,endy
box startx,starty,endx,endy,21
delay 1
box startx,starty,endx,endy,21
bra lmb_down
lmb_up
box startx,starty,endx,endy,21
mode jam1
requester1
movea.l window(pc),a0
lea body1text,a1
lea positivetext,a2
lea negativetext,a3
moveq #0,d0
moveq #0,d1
move.l #130,d2
move.l #50,d3
intlib autorequest
tst.l d0
bne new_coordinates
mode complement
box startx,starty,endx,endy,21
mode jam1
tst.l alldone
beq now_what ;finished drawing
bra check_for_message
new_coordinates
check_them
move.l startx,d0
move.l endx,d1
cmp.l d1,d0
blo.s nc1 ;startx < endx
exg d1,d0
move.l d0,startx
move.l d1,endx
nc1
move.l starty,d0
move.l endy,d1
cmp.l d1,d0
blo.s nc2 ;starty < endy
exg d0,d1
move.l d0,starty
move.l d1,endy
nc2
move.l startx,d0
sub.l normalizex,d0
fltdp
movedp xinc,d2
muldp
adddp xleft
movedp newxleft
move.l endx,d0
sub.l normalizex,d0
fltdp
movedp xinc,d2
muldp
adddp xleft
movedp xright
movedp newxleft,xleft
move.l starty,d0
sub.l normalizey,d0
fltdp
movedp yinc,d2
muldp
movedp d0,d2
movedp ytop,d0
subdp
movedp newytop
move.l endy,d0
sub.l normalizey,d0
fltdp
movedp yinc,d2
muldp
movedp d0,d2
movedp ytop,d0
subdp
movedp ybottom
movedp saveybottom
movedp newytop,ytop
requester2
movea.l window(pc),a0
lea body2text,a1
lea smalltext,a2
lea largetext,a3
moveq #0,d0
moveq #0,d1
move.l #130,d2
move.l #50,d3
intlib autorequest
tst.l d0
beq draw_large
draw_small
move.l #128,xlength
move.l #129,xlength1
move.l #128,ylength
move.l #129,ylength1
move.l #96,xoffset
move.l #164,yoffset
move.l #96,normalizex
move.l #36,normalizey
move.l #0,redraw
bra scale
draw_large
move.l #320,xlength
move.l #320,xlength1
move.l #200,ylength
move.l #200,ylength1
move.l #0,xoffset
move.l #199,yoffset
move.l #0,normalizex
move.l #0,normalizey
move.l #1,redraw
bra scale
no_message
add.w #1,across ;across one space
cmpa.l xlength1,across ;all way across yet ?
bne l2 ;branch if not
adddp ybottom,yinc ;increase yy by yscale
movedp ybottom
add.w #1,down ;down one space
cmpa.l ylength1,down ;all way down yet ?
bne l1 ;branch if not
move.l #0,alldone ;finished drawing
now_what
@cfm2 now_what_done
cmpi.l #mousebuttons,d2
beq zoom
andi.l #$0000ffff,d3
cmpi.w #'1',d3 :#1
beq.s do_palette11
cmpi.w #'2',d3 ;#2
beq do_palette21
cmpi.w #'3',d3 ;#3
beq do_palette31
cmpi.w #'4',d3 ;#4
beq do_palette41
cmpi.w #'5',d3 ;#5
beq do_palette51
cmpi.w #'6',d3 ;#6
beq do_palette61
cmpi.w #'7',d3 ;#7
beq do_palette71
cmpi.w #'8',d3 ;#8
beq do_palette81
cmpi.w #'9',d3 ;#9
beq do_palette91
cmpi.w #'0',d3 ;#0
beq do_palette01
cmpi.w #'c',d3
beq new_values
cmpi.w #'x',d3
beq redraw_it
cmpi.w #'q',d3
beq close_window
now_what_done
bra now_what
do_palette11
palette colormap1(pc),32
bra now_what
do_palette21
palette colormap2(pc),32
bra now_what
do_palette31
palette colormap3(pc),32
bra now_what
do_palette41
palette colormap4(pc),32
bra now_what
do_palette51
palette colormap5(pc),32
bra now_what
do_palette61
palette colormap6(pc),32
bra now_what
do_palette71
palette colormap7(pc),32
bra now_what
do_palette81
palette colormap8(pc),32
bra now_what
do_palette91
palette colormap9(pc),32
bra now_what
do_palette01
palette colormap0(pc),32
bra now_what
close_window
closemenu
closewindow
close_screen
closescreen
close_libs
closelib dpmath
closelib dptrans
close_gfx
closelib gfx
close_dos
closelib dos
close_int
closelib int
done
move.l stack,sp
rts
evenpc
stack dc.l 0 ;reserve storage locations
gfxbase dc.l 0
intbase dc.l 0
dosbase dc.l 0
dpmathbase dc.l 0
dptransbase dc.l 0
;library names
gfx dc.b 'graphics.library',0
evenpc
int dc.b 'intuition.library',0
evenpc
dos dc.b 'dos.library',0
evenpc
dpmath dc.b 'mathieeedoubbas.library',0
evenpc
dptrans dc.b 'mathieeedoubtrans.library',0
evenpc
myscreen:
dc.w 0,0,320,200,depth ;depth is 5
dc.b 0,1
dc.w 0
dc.w customscreen
dc.l 0,0,0,0
evenpc
mywindow
dc.w 0,0,320,200
dc.b 0,1
dc.l mousebuttons!mousemove!vanillakey!menupick
dc.l borderless!activate!mousereport!smartrefresh
dc.l gadget1,0
dc.l 0
dc.l 0,0
dc.w 0,0,0,0
dc.w customscreen
evenpc
v:
xleft dc.l 0,0 ;reserve space for both parts
xright dc.l 0,0
xx dc.l 0,0
xinc dc.l 0,0
ybottom dc.l 0,0
ytop dc.l 0,0
yinc dc.l 0,0
startx dc.l 0
starty dc.l 0
endx dc.l 0
endy dc.l 0
xlength dc.l 0
xlength1 dc.l 0
xoffset dc.l 0
normalizex dc.l 0
ylength dc.l 0
ylength1 dc.l 0
yoffset dc.l 0
normalizey dc.l 0
newxleft dc.l 0,0
newytop dc.l 0,0
saveybottom dc.l 0,0
alldone dc.l 0
redraw dc.l 0
e1 dc.l 0,0
e2 dc.l 0,0
c1 dc.l 0,0
c2 dc.l 0,0
f1 dc.l 0,0
f2 dc.l 0,0
a dc.l 0,0
b dc.l 0,0
twodp dc.l $40000000,0
type dc.w 0
evenpc
colormap1 ;my new palette
dc.w $000,$f0f,$d0f,$b0f,$90f,$70f,$50f,$30f
dc.w $10f,$00f,$03d,$05b,$079,$097,$0b5,$0d3
dc.w $0f0,$3f0,$6f0,$9f0,$bf0,$df0,$ff0,$fe0
dc.w $fd0,$fc0,$fa0,$f80,$f60,$f40,$f20,$f00
evenpc
colormap2
dc.w $000,$f00,$f20,$f40,$f60,$f80,$fa0,$fb0
dc.w $fc0,$fd0,$fe0,$ff0,$df0,$af0,$6f0,$3f0
dc.w $0f0,$0d3,$0a6,$06a,$03d,$00f,$30d,$60a
dc.w $a06,$d03,$f0f,$d0d,$a0a,$606,$303,$202
evenpc
colormap3
dc.w $000,$f00,$d00,$b00,$a00,$800,$600,$500
dc.w $300,$200,$100,$0f0,$0d0,$0b0,$0a0,$080
dc.w $060,$050,$030,$020,$010,$00f,$00d,$00b
dc.w $00a,$008,$006,$005,$004,$003,$002,$001
evenpc
colormap4
dc.w $000,$f00,$e00,$d00,$c00,$b00,$a00,$900
dc.w $800,$700,$600,$0f0,$0e0,$0d0,$0c0,$0b0
dc.w $0a0,$090,$080,$070,$060,$00f,$00e,$00d
dc.w $00c,$00b,$00a,$009,$008,$007,$006,$005
evenpc
colormap5
dc.w $000,$f00,$e20,$d40,$c60,$b80,$aa0,$8b0
dc.w $6c0,$4d0,$2e0,$0f0,$0e2,$0d4,$0c6,$0b8
dc.w $0aa,$08b,$06c,$04d,$02e,$00f,$00e,$00d
dc.w $00c,$00b,$00a,$009,$007,$005,$003,$001
evenpc
colormap6
dc.w $000,$400,$501,$720,$710,$821,$831,$841
dc.w $951,$a61,$a71,$a81,$b91,$ba1,$bb2,$cc2
dc.w $ac2,$9c2,$7c2,$6c2,$4d2,$2d1,$1d2,$1d4
dc.w $1e5,$1e7,$1ea,$1ec,$1ee,$0df,$0bf,$09f
evenpc
colormap7
dc.w $000,$620,$730,$951,$a72,$c93,$db4,$fd5
dc.w $ee4,$cd3,$9c2,$7a2,$591,$481,$270,$150
dc.w $062,$074,$067,$047,$008,$308,$709,$907
dc.w $a05,$a13,$b11,$b43,$c72,$da3,$dd3,$be4
evenpc
colormap8
dc.w $000,$fff,$ecd,$c9c,$b7a,$a59,$837,$726
dc.w $559,$66a,$77b,$99b,$aac,$ccd,$dde,$fff
dc.w $ded,$cdb,$bc9,$9b7,$8a6,$794,$685,$572
dc.w $58a,$69b,$7ab,$9bc,$acd,$bcc,$cee,$fff
evenpc
colormap9
dc.w $000,$fe0,$db0,$c90,$a60,$950,$730,$620
dc.w $fe0,$af0,$3f0,$0f3,$0fa,$0df,$07f,$00f
dc.w $fe0,$eb0,$c90,$b90,$a60,$940,$730,$620
dc.w $fe0,$de0,$ad0,$7c0,$5b0,$3a0,$270,$080
evenpc
colormap0
dc.w $000,$004,$008,$00b,$00f,$00b,$008,$004
dc.w $000,$430,$770,$ba0,$fe0,$ba0,$860,$430
dc.w $000,$300,$700,$a00,$e00,$a00,$700,$300
dc.w $000,$020,$040,$060,$080,$060,$040,$020
evenpc
menus
makemenu menu0,'Project',,0,1
makeitem menu0item0,'Sin(Z)',menu0item1,0,$153,$1e
makeitem menu0item1,'Cos(Z)',menu0item2,10,$53,$1d
makeitem menu0item2,'Sinh(Z)',menu0item3,20,$53,$1b
makeitem menu0item3,'Cosh(Z)',menu0item4,30,$53,$17
makeitem menu0item4,'Exp(Z)',,40,$53,$f
evenpc
messages
titlemsg dc.b 'COMPLEX ITERATIONS',0
evenpc
cmsg dc.b ' press c for main menu',0
evenpc
xmsg dc.b ' press x to switch picture size',0
evenpc
palmsg dc.b ' press 0 - 9 to change palettes',0
evenpc
zoommsg dc.b ' use the LMB to draw a ZOOM box',0
evenpc
lmbmsg dc.b 'NOW PRESS THE LEFT MOUSE BUTTON',0
evenpc
gadgets
makestrgadget gadget1,'C1',gadget2,40,75,100,9,$0,$1,$0,1,15
makestrgadget gadget2,'iC2',gadget3,180,75,100,9,$0,$1,$0,2,15
makestrgadget gadget3,'F1',gadget4,40,100,100,9,$0,$1,$0,3,15
makestrgadget gadget4,'iF2',gadget5,180,100,100,9,$0,$1,$0,4,15
makestrgadget gadget5,'Xleft',gadget6,40,150,100,9,$0,$1,$0,5,15
makestrgadget gadget6,'Ytop',gadget7,110,125,100,9,$0,$1,$0,6,15
makestrgadget gadget7,'Xright',gadget8,180,150,100,9,$0,$1,$0,6,15
makestrgadget gadget8,'Ybot',0,110,175,100,9,$0,$1,$0,8,15
evenpc
gadget1buffer dc.b '1.00000000000',0 ;C1
evenpc
gadget2buffer dc.b '0.00000000000',0 ;iC2
evenpc
gadget3buffer dc.b '0.00000000000',0 ;F1
evenpc
gadget4buffer dc.b '0.00000000000',0 ;iF2
evenpc
gadget5buffer dc.b '-4.0000000000',0 ;Xleft
evenpc
gadget6buffer dc.b '4.50000000000',0 ;Ytop
evenpc
gadget7buffer dc.b '4.00000000000',0 ;Xright
evenpc
gadget8buffer dc.b '-4.5000000000',0 ;Ybot
evenpc
simple_requesters
body1text ;intui-text structure for body text
dc.b 0,1,1,0
dc.w 0,0
dc.l 0,body1string,0
evenpc
body1string dc.b 'OK to ZOOM ?',0
evenpc
positivetext
dc.b 0,1,1,0
dc.w 0,0
dc.l 0,positivestring,0
evenpc
positivestring dc.b 'YES',0
evenpc
negativetext
dc.b 0,1,1,0
dc.w 0,0
dc.l 0,negativestring,0
evenpc
negativestring dc.b 'NO!',0
evenpc
body2text
dc.b 0,1,1,0
dc.w 0,0
dc.l 0,body2string,0
evenpc
body2string dc.b 'What Size ?',0
evenpc
smalltext
dc.b 0,1,1,0
dc.w 0,0
dc.l 0,smallstring,0
evenpc
smallstring dc.b 'SMALL',0
evenpc
largetext
dc.b 0,1,1,0
dc.w 0,0
dc.l 0,largestring,0
evenpc
largestring dc.b 'LARGE',0
evenpc
end